﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Web.Mvc;
using BSInstraAPI.Models;

namespace BSInstraAPI.Controllers
{

    public class UserController : ApiController
    {
        static readonly IUserRepository Repository = new UserRepository();

        //http://localhost:1526/api/user?token=13321321
        public IEnumerable<Users> GetAllUsers(string token)
        {
            return Repository.GetAllUsers(token);
        }

        //http://localhost:1526/api/user?token=13321321&loginid=liujun
        public Users Get(string token, string loginid)
        {
            return Repository.Get(token, loginid);
        }

        public bool GetUserTrue(string token, string loginid, string pass)
        {
            return Repository.Check(token, loginid, pass);
        }

        public bool Put(string token, string loginid, string pswd)
        {
            return Repository.Update(token, loginid, pswd);
        }
       
        public bool Put(string token, string loginid, string oldpass, string newpass)
        {
            return Repository.Update(token, loginid, oldpass, newpass);
        }
    }
}
